import Router from 'koa-router'
import { sendEmail } from './lib/mailer.js'

const router = new Router()

// test send mail
router.get('/api/test/send-email', async (ctx, next) => {
	const query = ctx.query || {}

	const testToken = query['test-token'] || ''
	console.log('testToken: ', testToken)

	if (testToken !== 'koo*189') {
		ctx.body = 'invalid token'
		return
	}

	sendEmail({
		subject: 'test title 测试标题',
		text: 'test content 测试内容，Date.now ' + Date.now()
	})

	ctx.body = 'send email'
})

export default router
